function findDuplicateJdcode(arr, propertyName) {
  // 用于存储每个 propertyValue 的计数和位置
  const propertyValueMap = {};
  // 遍历数组，统计每个 propertyValue 的出现次数和位置
  arr.forEach((item, index) => {
    const propertyValue = item[propertyName];
    if (!propertyValueMap[propertyValue]) {
      propertyValueMap[propertyValue] = {
        count: 0,
        positions: []
      };
    }
    propertyValueMap[propertyValue].count++;
    propertyValueMap[propertyValue].positions.push(index);
  });
  // 找出重复的 propertyValue 值
  const duplicates = [];
  for (const propertyValue in propertyValueMap) {
    if (propertyValueMap[propertyValue].count > 1) {
      let item = {}
      item[propertyName] = propertyValue;
      item.count = propertyValueMap[propertyValue].count,
      item.positions = propertyValueMap[propertyValue].positions
      duplicates.push(item);
    }
  }
  return duplicates;
}

// 示例数组
const arr = [
  { jdcode: 'A001', name: 'Item 1' },
  { jdcode: 'A002', name: 'Item 2' },
  { jdcode: 'A001', name: 'Item 3' },
  { jdcode: 'A003', name: 'Item 4' },
  { jdcode: 'A002', name: 'Item 5' },
  { jdcode: 'A003', name: 'Item 6' }
];

// 调用函数
const duplicates = findDuplicateJdcode(arr, 'jdcode');

// 输出结果
console.log(duplicates);